import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

/**
 * 通过 pathName 懒加载组件
 * @param {String} pathName
 */
export default pathName => {
  return resolve => {
    NProgress.start()
    import(/* webpackChunkName: "[request]" */ `../views/${pathName}`).then(mod => {
      resolve(mod)
    }).finally(() => {
      NProgress.done()
    })
  }
}
